const sql=require("../../config/request")
//获取全部user
function getData() {
    return sql("select * from user")
}
//获取条件成立的数据
function getDataIf(obj) {
    return sql("select * from user where username =?",[obj.username])
}
//创建用户到数据库
function addData(obj) {
    return sql('insert into user values(null,?,?,?,?,?,"员工")',[obj.username,obj.password,obj.createTime,obj.expireTime,obj.person])
}
//删除一条数据
function deleteData(obj) {
    console.log(obj.id)
    return sql('delete from user where id=?',[obj.id])
}
//查早一条数据
function selectDataId(obj){
    return sql('select * from user where id=?',[obj.id])
}
//修改名称和角色
function  updataColedata(obj) {
    return sql("update user set username=? , role=? where id=?",[obj.inp2,obj.cole,obj.updataid])

}
//修改密码 
function updatePasswordData(obj) {
    return sql('update user set password=? where username=?',obj)
}
module.exports={
    getData,
    getDataIf,
    addData,
    deleteData,
    selectDataId,
    updataColedata,
    updatePasswordData
}